<?php

class AuthPlugin extends Zend_Controller_Plugin_Abstract
{
    /**
     * @param Zend_Controller_Request_Abstract $request
     */
    public function preDispatch(Zend_Controller_Request_Abstract $request)
    {
        $user = JFactory::getUser();
        $moduleName = $request->getModuleName();
        switch ($moduleName) {
            case 'admin':
                $controllerName = $request->getControllerName();
                switch ($controllerName) {
                    case 'index':
                        break;
                    default:
                        if ($user->IsGuest) {
                            $flashMessenger = new Zend_Controller_Action_Helper_FlashMessenger();
                            $flashMessenger->addMessage('You Must Login First');
                            $this->_response->setRedirect('/classico/public/admin/index/index');
                        }
                        break;
                }
                break;
            case 'default':
                break;
        }
    }
}
